package day09.ExceptionTest;

import java.util.Scanner;

public class Test6 {
    public static void main(String[] args) {
        System.out.print("用户名:");
        String username = new Scanner(System.in).nextLine();
        System.out.print("密码:");
        String password = new Scanner(System.in).nextLine();
        try { //option + command = t
            login(username, password);
            System.out.println("欢迎登录");
        } catch (UsernameNotFoundException e) {
            System.out.println("用户名不正确");
        }catch (UserWrongPasswordException e){
            System.out.println("密码不正确");
        }


    }

    private static void login(String username, String password) throws UsernameNotFoundException, UserWrongPasswordException {
        if(!username.equals("abc")){
            throw new UsernameNotFoundException();
        }
        if(!password.equals("123")){
            throw  new UserWrongPasswordException();
        }
    }
}
